from selenium.webdriver.common.by import By

from common.Utils import BolgDriver


class BlogList:
    url = ""
    driver = ""
    def __init__(self):
        self.url = "http://8.137.19.140:9090/blog_list.html"
        self.driver = BolgDriver.driver
        self.driver.get(self.url)
    # 正常登录
    def BlogListByLogin(self):
        # 查找头像，用户名和github地址
        self.driver.find_element(By.CSS_SELECTOR, "body > div.container > div.left > div > img")
        self.driver.find_element(By.CSS_SELECTOR, "body > div.container > div.left > div > h3")
        self.driver.find_element(By.CSS_SELECTOR, "body > div.container > div.left > div > a")
        # 截图
        BolgDriver.getScreenShot()

    # 异常登录
    def BlogListByNotLogin(self):
        self.driver.back()
        # 截图
        BolgDriver.getScreenShot()
        #如果成功回到登录界面，那么找不到头像
        self.driver.find_element(By.CSS_SELECTOR,"body > div.container > div.left > div > img")

